package chai.ning.constructor;

public class Eagle {

	public static String sky = "湛蓝的天空";

	public static void show() {
		System.out.println(sky); // Eagle.sky
	}

	private String name;
	private int age;

	public Eagle(String name) {
		// 因为构造方法的参数名称是 name ，为了区分 参数 name 和 实例变量 name ，
		this.name = name; // 所以 等号之前的this不能省略
	}

	public Eagle(String name, int age) {
		this(name);
		this.age = age;
	}

	public void fly() {
		System.out.print(this.name + "在天上飞 : ");
		System.out.println(System.identityHashCode(this));
	}

	public void introduce() {
		System.out.println("name : " + name + " , age = " + age); // 在可以明确确定变量名称的前提下，可以省略 this
		System.out.println("name : " + this.name + " , age = " + this.age);
	}

	public static void main(String[] args) {

		// Eagle[] eagles = new Eagle[ 5 ];
		// System.out.println( Arrays.toString( eagles ) );

		Eagle e = new Eagle("猫头鹰");
		System.out.println(System.identityHashCode(e));
		e.fly();

		System.out.println("- - - - - - - - - - - - - - - - - -");

		Eagle a = new Eagle("宋祖英");
		System.out.println(System.identityHashCode(a));
		a.fly();

	}

}
